<template>
	<view>
		<view class="container">
			<view class="flex-box flex-between box1">
				<navigator open-type="navigate" hover-class="none" url="/pages/member/setting/setting">
					<image src="/static/icon/c-icon_setting.png" class="setting"></image>
				</navigator>
				<view class="flex-grow-1">
					<!--  -->
					<view @tap="jumpToPages" data-jump_type="2" data-url="/pages/member/base_info/base_info"><text class="fs40 pr20">{{ user_id && user_nickname ? user_nickname : '请登录'}}</text><text v-if="user_college && identify == 1" class="fs24 col89">{{ user_college }} </text></view>
					<!-- <view class="flex-box flex-between tixianbox">
						<view @tap="jumpToPages" data-jump_type="2" data-url="/pages/member/commission_detail/commission_detail">
							<text class="fs24 col89 pr20">佣金</text>
							<text class="fs34 colf8 ">{{ money }}</text>
						</view>
						<button @tap="jumpToPages" data-jump_type="2" data-url="/pages/member/cash_out/cash_out" class="tixian" >提现</button>
					</view> -->
				</view>
				<view @tap="jumpToPages" data-jump_type="2" data-url="/pages/member/base_info/base_info" class="avatar"><u-avatar :src="user_avatar" size="150" mode="aspectFill" shape="circle"></u-avatar></view>
			</view>
			<view class="flex-box flex-between bgf" style="padding: 0 40rpx 11rpx">
				<view @tap="jumpToPages" data-jump_type="2" data-url="/pages/member/sign_in/sign_in" class="img_personal">
					<view class="tip1">{{ sign_info.name }}</view>
					<view class="tip2">{{ sign_info.text }}</view>
					<image src="/static/images/img_personal1.png"></image>
				</view>
			</view>
			
			<block v-if='identify!=0'>
				<view class="navbox mt20">
					<template v-for="(item, index) in managernavs">
						<view @tap="jumpToPages" :data-jump_type="item.jump_type" :data-url="item.url" class="flex-box flex-between nav" hover-class="none">
							<view class="flex-box">
								<image :src="item.icon" class="pnavs"></image>
								<view class="fs32">{{item.title}}</view>
							</view>
							<image src="/static/icon/icon_close-r.png" class="icon_close-r"></image>
						</view>
					</template>
					<view class="fs38 fwb pt30 pb10">经纪人工具</view>
					<template v-for="(item, index) in toolnavs">
						<view @tap="jumpToPages" :data-jump_type="item.jump_type" :data-url="item.url" class="flex-box flex-between nav" hover-class="none">
							<view class="flex-box">
								<image :src="item.icon" class="pnavs"></image>
								<view class="fs32">{{item.title}}</view>
							</view>
							<image src="/static/icon/icon_close-r.png" class="icon_close-r"></image>
						</view>
					</template>
				</view>
			</block>
			
			<block v-else>
		
				<view class="navbox">
					<template v-for="(item, index) in usernavs">
						<view @tap="jumpToPages" :data-jump_type="item.jump_type" :data-url="item.url" class="flex-box flex-between nav" hover-class="none">
							<view class="flex-box">
								<image :src="item.icon" class="pnavs"></image>
								<view class="fs32">{{item.title}}</view>
							</view>
							<image src="/static/icon/icon_close-r.png" class="icon_close-r"></image>
						</view>
					</template>
				</view>	
			</block>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	
	const functions = require('../../../utils/functions.js');
	export default {
		data() {
			return {
				money: 0,
				user_id: 0,
				user_nickname: '',
				user_avatar: '',
				user_college: '',
				draw_prize_discription: '',
				init_sign_score: '',
				sign_info: {
					name: '您有积分待领取',
					text: '2积分'
				},
				today_is_sign: false,
				identify:0,//0用户，1经纪人
				usernavs: [
					{
						icon: '/static/icon/icon_pnav1.png',
						title: '我的收藏',
						jump_type: 2,
						url: '/pages/member/my_collection/my_collection'
					},
					{
						icon: '/static/icon/icon_pnav2.png',
						title: '帮你找房',
						jump_type: 2,
						url: '/pages/home/help_you/help_you'
					},
					// {
					// 	icon: '/static/icon/icon_pnav11.png',
					// 	title: '我的团队',
					// 	jump_type: 2,
					// 	url: '/pages/member/my_team/my_team'
					// }, 
					{
						icon: '/static/icon/icon_pnav8.png',
						title: '邀请好友',
						jump_type: 2,
						url: '/pages/member/invite/invite',
					},
					// {
					// 	icon: '/static/icon/icon_pnav12.png',
					// 	title: '我的消息',
					// 	jump_type: 2,
					// 	url: '/pages/home/chatlist/chatlist'
					// },
					{
						icon: '/static/icon/icon_pnav10.png',
						title: '我的问题',
						jump_type: 2,
						url: '/pages/member/ques_list/ques_list'
					},
					{
						icon: '/static/icon/icon_pnav11.png',
						title: '我的服务',
						jump_type: 2,
						url: '/pages/member/my_service/my_service'
					},
					
				],
				managernavs: [
					{
						icon: '/static/icon/icon_pnav1.png',
						title: '我的收藏',
						jump_type: 2,
						url: '/pages/member/my_collection/my_collection'
					},
					// {
					// 	icon: '/static/icon/icon_pnav11.png',
					// 	title: '我的团队',
					// 	jump_type: 2,
					// 	url: '/pages/member/my_team/my_team'
					// },
					{
						icon: '/static/icon/icon_pnav8.png',
						title: '邀请有奖',
						jump_type: 2,
						url: '/pages/member/invite/invite',
					},
					// {
					// 	icon: '/static/icon/icon_pnav12.png',
					// 	title: '我的消息',
					// 	jump_type: 2,
					// 	url: '/pages/home/chatlist/chatlist'
					// },
					{
						icon: '/static/icon/icon_pnav10.png',
						title: '我的问题',
						jump_type: 2,
						url: '/pages/member/ques_list/ques_list'
					},
				],
				toolnavs:[
									{
										icon: '/static/icon/icon_pnav11.png',
										title: '我的客户',
										jump_type: 2,
										url: '/pages/member/my_clients/my_clients'
									}, 
									{
										icon: '/static/icon/icon_pnav7.png',
										title: '客户公海',
										jump_type: 2,
										url: '/pages/member/clients_sea/clients_sea'
									},
									{
										icon: '/static/icon/icon_pnav2.png',
										title: '我的楼盘',
										jump_type: 2,
										url: '/pages/member/my_building/my_building'
									},
									
								]
			};
		},
		onShow: function () {
			this.initData();
		},
		onPullDownRefresh: function () {
			uni.showNavigationBarLoading(); //在标题栏中显示加载
	
			var that = this; //模拟加载
	
			setTimeout(function () {
				that.initData();
				uni.stopPullDownRefresh(); //停止下拉刷新
			}, 1500);
		},
		methods: {
			jumpToPages(event) {
				
				var that = this;
				var jump_type = Number(event.currentTarget.dataset.jump_type);
				var url = event.currentTarget.dataset.url;
				if (jump_type == 1) {
					uni.navigateTo({
						url: url
					});
				} else if (jump_type == 2) {
					app.globalData.nowThat = this;
					functions.checkLogin(function (ret) {
						if (ret) {
							uni.navigateTo({
								url: url
							});
						} else {
							functions.toast('请先登录');
						}
					});
				} else if (jump_type == 3) {
					var tel = app.globalData.config.platform_contact_tel;
					functions.phoneCall({
						phoneNumber: tel //仅为示例，并非真实的电话号码
					});
				}
			},
			
			initData() {
				var that = this;
				this.init_sign_score=app.globalData.config.init_sign_score;
				this.draw_prize_discription=app.globalData.config.draw_prize_discription
				if (!uni.getStorageSync('token')) {
					this.sign_info= {
							name: '您有积分待领取',
							text: app.globalData.config.init_sign_score + '积分'
						};
					return false;
				}
	
				functions.getAjaxData('/api/xiluhouse/User/index', {}, function (res) {
					app.globalData.userInfo = res.data;
					
				
					if (res.data.today_is_sign) {
						that.sign_info={
								name: '免费领积分',
								text: '做任务 轻松赚积分'
							};
					} else {
						that.sign_info={
								name: '您有积分待领取',
								text: res.data.now_sign_score + '积分'
							};
					}
					that.user_id = res.data.id;
					that.today_is_sign=res.data.today_is_sign;
					that.money=res.data.money;
					that.identify=res.data.is_broker - 1;
					that.user_nickname=res.data.nickname;
					that.user_avatar=res.data.avatar;
					that.user_college=res.data.college
				});
			}
		
		}
	}
</script>

<style lang="scss">
	.box1 .setting {
	    width: 34rpx;
	    height: 34rpx;
	    position: absolute;
	    top: 12rpx;
	    right: 40rpx;
	    z-index: 2;
	}
	.img_personal {
	    width: 100%;
	    height: 121rpx;
	    position: relative;
	}
	.img_personal image {
	    width: 100%;
	    height: 121rpx;
	    position: absolute;
	    top: 0;
	    left: 0;
	    z-index: 1;
	}
	.img_personal .tip1 {
	    position: relative;
	    z-index: 2;
	    padding: 32rpx 0 0 40rpx;
	    font-size: 28rpx;
	    color: #0091ff;
	}
	.img_personal .tip2 {
	    position: relative;
	    z-index: 2;
	    height: 27rpx;
	    background: linear-gradient(156deg, #6aa8e5 0%, #5783ec 100%);
	    border-radius: 14rpx;
	    font-size: 16rpx;
	    color: #fff;
	    line-height: 27rpx;
	    text-align: center;
	    margin-left: 40rpx;
	    display: inline;
	    padding: 0 10rpx;
	}
.container{background-color: #f6f7fa;}
.box1{padding: 42rpx 101rpx 48rpx 80rpx;background-color: #fff;}
.box1 .avatar{width: 150rpx;height: 150rpx;margin-left: 57rpx;}
.box1 .tixian{margin: 0;padding: 0;width: 80rpx;height: 40rpx;border-radius: 5rpx;background: var(--blue);font-size: 24rpx;color: #fff;line-height: 40rpx;text-align: center;}
.box1 .tixianbox{padding-top: 17rpx;}

.getreport{height: 162rpx;display: block;padding: 0 40rpx;background-color: #fff;}
.getreport image{width: 670rpx;height: 162rpx;}

.navbox{padding: 0 40rpx;background-color: #fff;}
.navbox .nav{height: 116rpx;border-bottom: 1px solid #f4f3f3;}
.navbox .nav:last-child{border-bottom: transparent;}
.navbox .pnavs{width: 42rpx;height: 42rpx;margin-right: 14rpx;margin-left: 20rpx;}
.navbox .icon_close-r{width: 25rpx;height: 25rpx;}

.container .quit{width: 640rpx;height: 90rpx;border-radius: 51rpx;background: var(--blue);box-shadow: 0rpx 4rpx 40rpx rgba(3,103,179,0.3);margin: 0;padding: 0;font-size: 30rpx;color: #fff;line-height: 90rpx;}

.quitbox{padding: 80rpx 55rpx;}
</style>
